package day10;

/**
 * 鱼和潜艇都能在水里游泳.
 * 声呐扫描水底的时候,能发现水中游动的物体.
 * 把游动定义成接口,鱼和潜艇实现此接口;
 * 实现声呐的扫描功能,能扫描所有移动的物体
 */

public interface Swim {
    void swimming();

}
class Fish implements Swim{

    @Override
    public void swimming() {
        System.out.println("鱼儿在水里游动");
    }
}
class Submarine implements Swim
{

    @Override
    public void swimming() {
        System.out.println("潜水艇在水中潜行");
    }
}
interface Scan{
    void work();
}
class Sonar implements Scan{
private String brand;

    public Sonar(String brand) {
        this.brand = brand;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    @Override
    public void work() {
        System.out.println(brand+"牌声呐正在扫描水中所有游动的物体");
    }
}
class Test3{
    public static void main(String[] args) {
        Swim a=new Fish();
        a.swimming();
        Swim b=new Submarine();
        b.swimming();
        Scan c=new Sonar("爱国者");
        c.work();
    }
}